<template>
    <div id='after-loan-detail'>
       <!--  <h1 class="card-title">
           <span>贷后详情</span>
       </h1> -->
        
        <div class="loading-min-height">
            <loading v-show='loading' mode='full'></loading>
            <transition name='fade'>
                <div class="result-info" v-if='!loading'>
                    <div class="detail-info">
                        <p>状态: <span>{{info.statusStr || placeholder}}</span></p>
                        <p>放款形式: <span>{{info.loanLendType || placeholder}}</span></p>
                        <p>专属业务客服: <span>{{info.loanOperator || placeholder}}</span></p>
                        <p>专属催收客服: <span>{{info.operator || placeholder}}</span></p>
                        <p>历史催收客服: <span>{{info.historyOperator || placeholder}}</span></p>
                    </div>
                    <div class="card-content">
                        <div class="sub-title">
                            <span class="title">借款人基本信息</span>
                            <span class="button auto transparent tar" @click='goDetail(basicInfo.authCheckRecordId)'>查看认证详情</span>
                        </div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">借款人姓名</div>
                                <div class="result-info__value">{{basicInfo.name || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">手机号</div>
                                <div class="result-info__value">{{basicInfo.phone || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">QQ</div>
                                <div class="result-info__value">{{basicInfo.qq || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">来源渠道</div>
                                <div class="result-info__value">{{basicInfo.authSource || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">认证时间</div>
                                <div class="result-info__value">{{basicInfo.authApplyTime || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">认证地址</div>
                                <div class="result-info__value">{{basicInfo.authLocate || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">身份证地址</div>
                                <div class="result-info__value">{{basicInfo.address || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">认证设备型号</div>
                                <div class="result-info__value">{{basicInfo.authDeviceModel || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">已成功借款次数</div>
                                <div class="result-info__value">{{basicInfo.lendTime}}</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content">
                        <div class="sub-title"><span class="title">借款申请基本信息</span></div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">申请时IP</div>
                                <div class="result-info__value">{{loanInfo.loanIp || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">定位地址</div>
                                <div class="result-info__value">{{loanInfo.authLocate || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">申请时间</div>
                                <div class="result-info__value">{{loanInfo.loanApplyTime || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">申请来源渠道</div>
                                <div class="result-info__value">{{loanInfo.loanSource || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">申请设备</div>
                                <div class="result-info__value">{{loanInfo.loanDeviceModel || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">申请金额</div>
                                <div class="result-info__value">{{loanInfo.applyAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">借款周期</div>
                                <div class="result-info__value">{{loanInfo.applyCycle || placeholder}}天</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">逾期罚息</div>
                                <div class="result-info__value">{{loanInfo.overDueCharge | toPercent}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">服务费</div>
                                <div class="result-info__value">{{loanInfo.serviceAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">到期应还款</div>
                                <div class="result-info__value">{{loanInfo.needRepayAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">收款银行卡</div>
                                <div class="result-info__value">{{loanInfo.cardName || placeholder}}</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content">
                        <div class="sub-title"><span class="title">放款信息</span></div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">放款金额</div>
                                <div class="result-info__value">{{lendInfo.lendAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">借款周期</div>
                                <div class="result-info__value">{{lendInfo.lendCycle || placeholder}}天</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">服务费</div>
                                <div class="result-info__value">{{lendInfo.serviceAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">到账金额</div>
                                <div class="result-info__value">{{lendInfo.lendRealAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">到期应还款</div>
                                <div class="result-info__value">{{lendInfo.lendAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">收款银行卡</div>
                                <div class="result-info__value">{{lendInfo.cardName || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">状态</div>
                                <div class="result-info__value">{{lendInfo.lendStatus || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">打款时间</div>
                                <div class="result-info__value">{{lendInfo.lendTime || placeholder}}</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content">
                        <div class="sub-title"><span class="title">逾期信息</span></div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">逾期利率</div>
                                <div class="result-info__value">{{overDueInfo.overDueCharge | toPercent}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">逾期天数</div>
                                <div class="result-info__value">{{overDueInfo.overDueDays || placeholder}}天</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content" >
                    <!-- <div class="card-content"> -->
                        <div class="sub-title"><span class="title">iCloud账号信息</span></div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">AppleID</div>
                                <div class="result-info__value">{{icouldInfo.appleId || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">邮箱密码</div>
                                <div class="result-info__value">{{icouldInfo.emailPwd || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">出生日期</div>
                                <div class="result-info__value">{{icouldInfo.bornDay | dateFormat('YYYY-MM-DD')}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">密码</div>
                                <div class="result-info__value">
                                    {{icouldInfo.applePwd || placeholder}}
                                </div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">安全问题1</div>
                                <div class="result-info__value">{{icouldInfo.firstQuestion || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">答案1</div>
                                <div class="result-info__value">{{icouldInfo.firstAnswer || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">安全问题2</div>
                                <div class="result-info__value">{{icouldInfo.secondQuestion || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">答案2</div>
                                <div class="result-info__value">{{icouldInfo.secondAnswer || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">安全问题3</div>
                                <div class="result-info__value">{{icouldInfo.thirdQuestion || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">答案3</div>
                                <div class="result-info__value">{{icouldInfo.thirdAnswer || placeholder}}</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content">
                        <div class="sub-title"><span class="title">还款信息</span></div>
                        <ul class="result-info__list">
                            <li class="result-info__item">
                                <div class="result-info__key">应还款总额</div>
                                <div class="result-info__value">{{repayInfo.repayTotalAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">应还本金</div>
                                <div class="result-info__value">{{repayInfo.repayAmount | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">逾期利息</div>
                                <div class="result-info__value">{{repayInfo.overDueAmount  | toYuan}}元</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">支付手续费</div>
                                <div class="result-info__value">{{repayInfo.name || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">还款时间</div>
                                <div class="result-info__value">{{repayInfo.repayTime || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">还款账号</div>
                                <div class="result-info__value">{{repayInfo.cardName || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">状态</div>
                                <div class="result-info__value">{{repayInfo.repayStatus || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">约定还款日</div>
                                <div class="result-info__value">{{repayInfo.needRepayTime || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">展期次数</div>
                                <div class="result-info__value">{{repayInfo.extendTimes || placeholder}}</div>
                            </li>
                            <li class="result-info__item full" v-if='repayInfo.repayPartRemarks'>
                                <div class="result-info__key">部分结清备注</div>
                                <div class="result-info__value">
                                    <p v-for='(item,index) in repayInfo.repayPartRemarks'>
                                        {{index + 1}}.{{item || placeholder}}
                                    </p>
                                </div>
                            </li>
                            <li class="result-info__item full">
                                <div class="result-info__key">剩余金额</div>
                                <div class="result-info__value">{{repayInfo.surplusNeedRepayAmount | toYuan}}元</div>
                            </li>
                        </ul>
                    </div>

                    <div class="card-content">
                        <div class="sub-title">
                            <span class="title">通讯录信息</span>
                        </div>
                        <div class='loading-min-height'>
                            <loading v-show='loading_contact' mode='full'></loading>
                            <p class='no-data' v-if='!loading_contact && !records.length'>暂无数据</p>
                            <div class="table-list" v-if='records.length'>
                                <table>
                                    <thead class="table-list__head">
                                        <tr>
                                            <th>通讯录号码</th>
                                            <th>通讯录名字</th>
                                            <th>通话次数</th>
                                            <th>通话时长</th>
                                            <th>主叫次数</th>
                                            <th>主叫时长</th>
                                            <th>被叫次数</th>
                                            <th>被叫时长</th>
                                        </tr>
                                    </thead>
                                    <tbody class='table-list__body have-border'>
                                        <tr v-for='item in records'>
                                            <td>{{ item.mobile || placeholder }}</td>
                                            <td>{{ item.contactName || placeholder }}</td>
                                            <td>{{ item.talk_count || placeholder }}</td>
                                            <td>{{ item.talk_seconds | secondFormat }}</td>
                                            <td>{{ item.call_count || placeholder }}</td>
                                            <td>{{ item.call_seconds | secondFormat }}</td>
                                            <td>{{ item.called_count || placeholder }}</td>
                                            <td>{{ item.called_seconds | secondFormat }}</td>
                                        </tr>
                                    </tbody>
                                </table>
                                <pagination
                                    :current-page='listInfo.pageNum'
                                    :total-page='listInfo.totalPage'
                                    @pageChange='getContactList'></pagination>
                            </div>
                        </div>
                    </div>

                    <div class="card-content" v-if='followInfo.length'>
                        <div class="sub-title"><span class="title">跟进记录</span></div>
                        <ul class="result-info__list follow-list" v-for='item in followInfo'>
                            <li class="result-info__item">
                                <div class="result-info__key">跟进时间</div>
                                <div class="result-info__value">{{item.time || placeholder}}</div>
                            </li>
                            <li class="result-info__item">
                                <div class="result-info__key">跟进方式</div>
                                <div class="result-info__value">{{item.followWay || placeholder}}</div>
                            </li>
                            <li class="result-info__item full" :class='{error:item.status}'>
                                <div class="result-info__key">跟进情况描述</div>
                                <div class="result-info__value">{{item.info || placeholder}}</div>
                            </li>
                        </ul>
                    </div>
                    
            
                    <div class="footer-button" v-if='info.status == 0'>
                        <div class="button mid success" 
                            @click='show_modal_add = true'>添加跟进记录</div>
                        <div class="button mid success" 
                            @click='show_modal_add_status = true'>添加跟进状态</div>
                    </div>
                </div>
            </transition>
        </div>

        <modal  
            :show='show_modal_add' 
            title='添加跟进情况描述'
            closeButton
            confirm-text=''
            cancle-text=''
            class='modal-add'
            @close='show_modal_add=false'>
            <div class="modal-form-wrap">
                <ul class='modal-form'>
                    <li class='form-item'>
                        <span class="form-item__key">是否为异常单</span>
                        <div class="form-item__value">
                            <radio-group v-model='status'>
                                <radio :value='1'>是</radio>
                                <radio :value='0'>否</radio>
                            </radio-group>
                        </div>
                    </li>
                </ul>
                <tab-box @tab-click='setType'>
                    <tab name='电话'>
                        <ul class='modal-form'>
                            <li class='form-item'>
                                <span class="form-item__key">选择通话记录</span>
                                <div class="form-item__value">
                                    <select-group v-model='mobileRecord'>
                                        <select-option v-for='item in mobileInfo' :key='item.phone' :value='item.phone' :text="'手机号码：'+item.phone+'-----通话次数：'+item.talk_count"></select-option>
                                    </select-group>
                                </div>
                            </li>
                        </ul>
                        <textarea class='modal__textarea' rows="5" placeholder="请输入本次电话跟进的情况描述" v-model='desc'></textarea>
                        <button-loading :loading='loading_add' :mid='true' @click='addHandle'>保存</button-loading>
                    </tab>
                    <tab name='微信'>
                        <textarea class='modal__textarea' rows="5" placeholder="请输入本次微信跟进的情况描述" v-model='desc'></textarea>
                        <button-loading :loading='loading_add' :mid='true' @click='addHandle'>保存</button-loading>
                    </tab>
                    <tab name='QQ'>
                        <textarea class='modal__textarea' rows="5" placeholder="请输入本次QQ跟进的情况描述" v-model='desc'></textarea>
                        <button-loading :loading='loading_add' :mid='true' @click='addHandle'>保存</button-loading>
                    </tab>
                </tab-box>
            </div>
        </modal>

        <modal  
            :show='show_modal_add_status' 
            title='添加跟进状态'
            class='modal-add-status'
            :loading='loading_add_status'
            @confirm='addStatusHandle'
            @close='show_modal_add_status=false'>
            <div class="modal-form-wrap">
                <ul class='modal-form'>
                    <li class='form-item'>
                        <span class="form-item__key">状态</span>
                        <div class="form-item__value">
                            <select-group v-model='statusSelect'>
                                <select-option v-for='item in statusList' :key='item.name' :value='item.name' :text='item.name'></select-option>
                            </select-group>
                        </div>
                    </li>
                </ul>
            </div>
        </modal>
    </div>
</template>

<script>
    import { Promise } from 'es6-promise'
    import footerBar from '../components/FooterBar.vue'
    import selectGroup from '../components/SelectGroup.vue'
    import selectOption from '../components/SelectOption.vue'
    import radioGroup from '../components/RadioGroup.vue'
    import datePicker from '../components/DatePicker.vue'
    import areaSelect from '../components/AreaSelect.vue'
    import radio from '../components/Radio.vue'
    import loading from '../components/Loading.vue'
    import tabBox from '../components/TabBox.vue'
    import tab from '../components/Tab.vue'
    import checkBox from '../components/CheckBox.vue'
    import toolTip from '../components/ToolTip.vue'
    import modal from '../components/Modal.vue'
    import confirm from '../components/Confirm.vue'
    import buttonLoading from '../components/ButtonLoading.vue'
    import pagination from '../components/Pagination.vue'
    import dateFormat from '../filters/filter-dateFormat'
    import toYuan from '../filters/filter-toYuan'
    import toPercent from '../filters/filter-toPercent'
    import  { mapGetters, mapActions }  from 'vuex'
    import { authApplyDetailValidation } from '../validation/validation'
    import Storage from '../utils/storage'
    import { repayApi, icloudApi, systemApi, loanApi, authApi, allApi, lenderApi } from '../api/api'
    import moment from 'moment'


    export default {
        components:{
            footerBar,
            selectGroup,
            selectOption,
            radioGroup,
            tabBox,
            tab,
            radio,
            checkBox,
            areaSelect,
            loading,
            toolTip,
            modal,
            confirm,
            buttonLoading,
            pagination,
            datePicker
        },
        filters:{
            dateFormat,
            toYuan,
            toPercent,
            booleanToStr(boolean){
                if(boolean === true){
                    return '是'
                }
                else{
                    return '否'
                }
            }
        },
        data() {
            return {
                listInfo:{},
                records:[],
                loading_contact:false,
                id:this.$route.params.id,
                placeholder:'--',
                desc:'',
                show_modal_reject:false,
                show_modal_icloud:false,
                show_modal_add_status:false,
                show_modal_add:false,
                loading_add:false,
                loading_add_status:false,
                loading_reject:false,
                loading_icloud:false,
                loading_set_icloud:false,
                loading_pass:false,
                loading:false,
                amount:'',
                recommend:0,
                curItem:{},
                info:{},
                statusList:[],
                allModels:[],
                deviceModel:{
                    value:'',
                    text:'请选择手机型号'
                },
                icloudPwd:'',
                icloudRePwd:'',
                isSetPwd:'',
                supportCycles:[],
                supportCycle:{
                    value:'',
                    text:'请选择周期'
                },
                type:{
                    value:'',
                    text:'请选择跟进方式'
                },
                mobileRecord:{
                    value:'',
                    text:'请选择一条通话记录'
                },
                statusSelect:{
                    value:'',
                    text:'请选择状态'
                },
                followType:2,
                status:'',
                imei:'',
                seriaNumber:'',
                rejectReason:'',
                rejectType:'',
                basicStatus:'',
                idCardStatus:'',
                mobileStatus:'',
                contactStatus:'',
            }
        },
        computed:{
            ...mapGetters([
                'msgTip',
                'localInfo'
            ]),
            amountToFen(){
                return (this.amount * 100).toFixed(0)
            },
            currentPage(){
                if(_.isEmpty(this.listInfo)) return 1
                return this.listInfo.pageNum
            },
            allAuth(){
                let basicPass = this.basicStatus === 0
                let idCardPass = this.idCardStatus === 0
                let mobilePass = this.mobileStatus === 0
                let contactPass = this.contactStatus === 0

                if(basicPass && idCardPass && mobilePass && contactPass) return true

                return false
            },
            basicInfo(){
                return this.info.report && this.info.report.basicInfo || {}
            },
            loanInfo(){
                return this.info.report && this.info.report.loanInfo || {}
            },
            lendInfo(){
                return this.info.report && this.info.report.lendInfo || {}
            },
            overDueInfo(){
                return this.info.report && this.info.report.overDueInfo || {}
            },
            repayInfo(){
                return this.info.report && this.info.report.repayInfo || {}
            },
            followInfo(){
                return this.info.report && this.info.report.followInfo || []
            },
            icouldInfo(){
                return this.info.report && this.info.report.icouldInfo || {}
            },
            mobileInfo(){
                return this.info.report && this.info.report.mobileInfo || []
            },
        },
        methods:{
            // actions
            ...mapActions([
                'showLoading',
                'hideLoading',
                'setMsgTip'
            ]),

            // filters
            timestampToDate(timestamp){
                if(!timestamp) return this.placeholder
                return moment(timestamp).format('YYYY-MM-DD')
            },

            // function
            goDetail(id){
                this.$router.push({
                    name:'auth-apply-detail',
                    params:{
                        id:id
                    }
                })
            },
            userReject(){
                this.rejectType = 'user'
                this.show_modal_reject = true
            },
            reject(){
                this.rejectType = ''
                this.show_modal_reject = true
            },
            getIcloud(){
                this.loading_icloud = true
                loanApi.useICouldAccount({
                    id:this.id
                })
                .then(result=>{

                    this.getInfo()
                    this.loading_icloud = false
                })
                .catch(error => {
                    console.error(error)
                    this.loading_icloud = false
                })
            },
            setIcloudPwd(){
                if(!this.icloudPwd){
                    this.setMsgTip({
                        text:'请输入密码',
                        type:'warn'
                    })
                    return
                }
                if(this.icloudPwd != this.icloudRePwd){
                    this.setMsgTip({
                        text:'两次输入的密码不一致',
                        type:'warn'
                    })
                    return
                }
                if(this.icloudPwd == this.icouldInfo.emailPwd){
                    this.setMsgTip({
                        text:'新密码不能与旧密码相同',
                        type:'warn'
                    })
                    return
                }
                this.loading_set_icloud = true
                icloudApi.resetPwd({
                    id:this.icouldInfo.id,
                    newPwd:this.icloudPwd
                })
                .then(result=>{
                    this.show_modal_icloud = false
                    this.loading_set_icloud = false
                    Storage.set(`shoujidai_${this.icouldInfo.id}_pwd`,true)
                    this.isSetPwd = true
                    this.getInfo()
                })
                .catch(error => {
                    console.error(error)
                    this.loading_set_icloud = false
                })
            },  
            getInfo(){
                this.loading = true
                repayApi.detail({
                    id:this.id
                })
                .then(result=>{
                    this.info = result
                    this.loading = false
                })
                .catch(error => {
                    console.error(error)
                    this.loading = false
                })
            },
            getStatusList(){
                repayApi.followStatusList()
                .then(result=>{
                    this.statusList = result
                })
                .catch(error => {
                    console.error(error)
                })
            },
            getCycles(){
                systemApi.allCycles()
                .then(result=>{
                    this.supportCycles = result
                })
                .catch(error => {
                    console.error(error)
                })
            },
            getAllModels(){
                systemApi.allModels()
                .then(result=>{
                    this.allModels = result
                })
                .catch(error => {
                    console.error(error)
                })
            },
            setType(index){
                if(index == 0){
                    this.followType = 2
                    return
                }
                if(index == 1){
                    this.type = '微信'
                    this.followType = 1
                    return
                }
                if(index == 2){
                    this.type = 'QQ'
                    this.followType = 1
                    return
                }
            },
            addStatusHandle(){
                if(this.statusSelect.value === ''){
                    this.setMsgTip({
                        text:'请选择状态',
                        type:'warn'
                    })
                    return
                }
                this.loading_add_status = true
                repayApi.addFollowStatus({
                    id:this.id,
                    followStatus:this.statusSelect.value,
                })
                .then(result=>{
                    this.setMsgTip({
                        text:'添加跟进状态成功',
                        type:'success'
                    })
                    this.loading_add_status = false
                    this.show_modal_add_status = false
                    this.getInfo()
                })
                .catch(error => {
                    console.error(error)
                    this.loading_add_status = false
                })
            },
            addHandle(){
                let followWay = this.type
                if(this.status === ''){
                    this.setMsgTip({
                        text:'请选择是否为异常单',
                        type:'warn'
                    })
                    return
                }
                if(this.followType == 2){
                    followWay = this.mobileRecord.value
                    if(this.mobileRecord.value == ''){
                        this.setMsgTip({
                            text:'请选择一条通话记录',
                            type:'warn'
                        })
                        return
                    }
                }
                if(!this.desc){
                    this.setMsgTip({
                        text:'请输入本次跟进的情况描述',
                        type:'warn'
                    })
                    return
                }
                this.loading_add = true
                repayApi.addFollow({
                    id:this.id,
                    info:this.desc,
                    followWay:followWay,
                    status:this.status,
                    followType:this.followType
                })
                .then(result=>{
                    this.setMsgTip({
                        text:'添加跟进情况成功',
                        type:'success'
                    })
                    this.loading_add = false
                    this.getInfo()
                })
                .catch(error => {
                    console.error(error)
                    this.loading_add = false
                })
            },
            passHandle(){

                if(!this.amount){
                    this.setMsgTip({
                        text:'请输入放款金额原因',
                        type:'warn'
                    })
                    return
                }
                if(this.supportCycle.value === ''){
                    this.setMsgTip({
                        text:'请选择借款周期',
                        type:'warn'
                    })
                    return
                }
                if(this.seriaNumber === ''){
                    this.setMsgTip({
                        text:'请输入序列号',
                        type:'warn'
                    })
                    return
                }
                if(this.imei === ''){
                    this.setMsgTip({
                        text:'请输入手机IMEI',
                        type:'warn'
                    })
                    return
                }
                if(this.deviceModel.value === ''){
                    this.setMsgTip({
                        text:'请选择手机型号',
                        type:'warn'
                    })
                    return
                }

                this.loading_pass = true
                loanApi.pass({
                    id:this.id,
                    lendAmount:this.amountToFen,
                    cycleId:this.supportCycle.value,
                    seriaNumber:this.seriaNumber,
                    imei:this.imei,
                    deviceModel:this.deviceModel.text,
                })
                .then(result=>{
                    this.loading_pass = false
                    this.show_modal_pass = false
                    this.$router.back()
                })
                .catch(error => {
                    console.error(error)
                    this.loading_pass = false
                })
            },
            getContactList(num = 1){
                this.loading_contact = true
                repayApi.getContact({
                    id:this.id,
                    pageSize:10,
                    pageIndex:num,
                })
                .then(result=>{
                    this.listInfo = result
                    this.records = result.records || []
                    if(result.totalPage < result.pageNum){
                        this.getList(result.totalPage)
                    }
                    this.loading_contact = false
                })
                .catch(error => {
                    console.error(error)
                    this.loading_contact = false
                })
            },
            rejectHandle(){

                if(!this.rejectReason){
                    this.setMsgTip({
                        text:'请输入审核拒绝原因',
                        type:'warn'
                    })
                    return
                }
                this.loading_reject = true
                if(this.rejectType == 'user'){
                    loanApi.userReject({
                        id:this.id,
                        rejectReason:this.rejectReason,
                    })
                    .then(result=>{
                        this.loading_reject = false
                        this.show_modal_reject = false
                        this.$router.back()
                    })
                    .catch(error => {
                        console.error(error)
                        this.loading_reject = false
                    })
                    return
                }
                loanApi.reject({
                    id:this.id,
                    rejectReason:this.rejectReason,
                })
                .then(result=>{
                    this.loading_reject = false
                    this.show_modal_reject = false
                    this.$router.back()
                })
                .catch(error => {
                    console.error(error)
                    this.loading_reject = false
                })
            }
        },
        created(){
            this.getContactList()
            this.getInfo()
            this.getStatusList()
            // this.getAllModels()
        }
    }
</script>

<style lang="scss">
    @import "../sass/variables";
    @import "../sass/extends";
    @import "../sass/mixins";

    #after-loan-detail{
        .footer-button{
            padding-top: 50px;
            display: flex;
            justify-content: center;
            .button{
                margin:0 20px;
            }
        }
        .result-info__item{
            &.error{
                .result-info__key,.result-info__value{
                    color:$red;
                }
            }
        }
        .detail-info{
            font-size: 14px;
            line-height: 1.5;
            padding-top:10px;
            color:$importColor;
            p{
                padding-top: 10px;
            }
            span{
                font-weight: normal;
            }
        }
        .modal-add{
            textarea{
                margin-bottom: 15px;
            }
        }
        .follow-list{
            padding-bottom: 15px;
            border-bottom: 1px solid $sectionColor;
        }
    }
</style>
